package com.sfjswl.fp.core.relation;

import com.sfjswl.fp.common.enums.NodeRunStateEnum;
import com.sfjswl.fp.core.base.BaseNode;
import com.sfjswl.fp.core.base.BaseRelation;
import com.sfjswl.fp.core.context.RuleContext;
import com.sfjswl.fp.core.utils.RuleLinkedList;

public final class True  extends BaseRelation {

  @Override
  protected NodeRunStateEnum processNode(RuleContext ctx) {
    RuleLinkedList<BaseNode> children = this.getChildren();
    if (children == null || children.isEmpty()) {
      return NodeRunStateEnum.TRUE;
    }
    for (RuleLinkedList.Node<BaseNode> listNode = children.getLeft(); listNode != null; listNode = listNode.next) {
      BaseNode node = listNode.item;
      if (node != null) {
        node.process(ctx);
      }
    }

    return NodeRunStateEnum.TRUE;
  }
}
